package edu.jiefengli.course_selection_system.pojo.entity;

import lombok.Data;

@Data
public class Result<T> {
    private int code; // 响应码
    private String message; // 响应消息
    private T data; // 响应数据

    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 省略getter和setter方法

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "success", data);
    }


    public static <T> Result<T> success(String message, T data) {
        return new Result<>(200, message, data);
    }

    public static Result success() {
        return new Result<>(200, "success", null);
    }

    public static Result error(int code, String message) {
        return new Result<>(code, message, null);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(500, message, null);
    }
}
